#!/bin/bash


echo "========================================================================="
echo "Thanks for using Transmission for CentOS/RadHat Auto-Install Script"
echo "========================================================================="

yum -y install gcc gcc-c++ m4 make automake libtool gettext openssl-devel pkgconfig perl-libwww-perl perl-XML-Parser curl curl-devel libevent-devel libevent libidn-devel zlib-devel 

yum -y upgrade

cd /usr/local/src
wget https://cc158158.googlecode.com/svn/trunk/bt/intltool-0.40.6.tar.gz
tar zxf intltool-*.tar.gz
cd intltool-*
./configure --prefix=/usr
make -s
make -s install
cd ..

wget https://cc158158.googlecode.com/svn/trunk/bt/libevent-2.0.14-stable.tar.gz
tar zxf libevent*
cd libevent*
./configure
make -s
make -s install
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

echo install Transmisson

cd /usr/local/src
wget https://cc158158.googlecode.com/svn/trunk/bt/transmission-2.33.tar.bz2
tar xjf transmission-*.tar.bz2
cd transmission-*
./configure --prefix=/usr
make -s
make -s install

useradd -m transmission
passwd -d transmission


wget -O /etc/init.d/transmissiond https://cc158158.googlecode.com/svn/trunk/bt/transmission.sh
chmod 755 /etc/init.d/transmissiond
chkconfig --add transmissiond
chkconfig --level 345 transmissiond on

service transmissiond start
service transmissiond stop


mkdir -p /home/transmission/Downloads/
chown -R transmission.transmission /home/transmission/Downloads/
chmod g+w /home/transmission/Downloads/

wget https://cc158158.googlecode.com/svn/trunk/bt/settings_hostloc.json
mv -f settings_hostloc.json /home/transmission/.config/transmission/settings.json
service transmissiond start

echo "========================================================================="
echo "Installation Successful"
echo "========================================================================="
echo ""
echo "Login: http://ip:9090"
echo ""
echo "Default username: av600"
echo ""
echo "Default password: *********"
echo ""
echo "Download Folder: home/transmission/Downloads/"
echo ""
echo "Please change your username(rpc-username) and password(rpc-password) in the file :"
echo "/home/transmission/.config/transmission/settings.json"
echo ""
echo "========================================================================="




